package com.sims.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.sims.bean.SeatChart;
import com.sims.beanEnhanced.StudentSeatChart;
import com.sims.dao.ISeatChartDAO;
import com.sims.util.Constant;
import com.sims.util.HttpSessionUtil;

public class SeatChartService {
	
	@Autowired
	ISeatChartDAO seatChartDAO;

	public Map<String, String> findSeatChart(List<StudentSeatChart> seatChartList) {
		
		Map<String, String> result = new HashMap<String, String>();
			
		List<StudentSeatChart> temp = seatChartDAO.findStudentSeatChartByCid(HttpSessionUtil.getUserClassId());
		System.out.println(temp.size());
		for (StudentSeatChart seatChart : temp) {
			seatChartList.add(seatChart);
		}
		result.put(Constant.SUCCESS, null);
		return result;
	}

	public Map<String, String> modifySeatChart(List<SeatChart> seatChartList) {
		Map<String, String> result = new HashMap<String, String>();
		for (int i = 0; i < seatChartList.size(); i++) {
			seatChartDAO.attachDirty(seatChartList.get(i));
		}
		result.put(Constant.SUCCESS, null);
		return result;
	}
}
